# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=gstreamer
pkgver=1.24.3
pkgrel=0
pkgdesc="GStreamer streaming media framework"
url="https://gstreamer.freedesktop.org"
arch="all"
license="LGPL-2.0-or-later"
replaces="gstreamer1"
depends_dev="libxml2-dev"
makedepends="$depends_dev
	bison
	flex
	glib-dev
	gobject-introspection-dev
	libcap-dev
	libcap-utils
	meson
	perl
	"
subpackages="
	$pkgname-dev
	$pkgname-doc
	$pkgname-tools
	$pkgname-lang
	"
source="https://gstreamer.freedesktop.org/src/gstreamer/gstreamer-$pkgver.tar.xz"
# setcap: gst-ptp-helper
# FIXME: two tests fail
options="setcap !check"

# secfixes:
#   1.18.4-r0:
#     - CVE-2021-3497
#     - CVE-2021-3498

build() {
	CFLAGS="$CFLAGS -O2" \
	CXXFLAGS="$CXXFLAGS -O2" \
	CPPFLAGS="$CPPFLAGS -O2" \
	abuild-meson \
		-Db_lto=true \
		-Dintrospection=enabled \
		-Dbash-completion=disabled \
		-Dpackage-name="GStreamer (Alpine Linux)" \
		-Dpackage-origin="https://alpinelinux.org" \
		. output
	meson compile -C output
}

check() {
	meson test --no-rebuild --print-errorlogs -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

dev() {
	default_dev

	# Support for debugging.
	amove usr/share/gdb
	amove usr/share/gstreamer-*/gdb

	# Unit test libraries.
	amove usr/bin/gst-tester-*
	amove usr/lib/libgstcheck-*.so.*
	amove usr/lib/girepository-1.0/GstCheck-*.typelib
}

doc() {
	default_doc
	replaces="${pkgname}1-doc"
}

tools() {
	pkgdesc="Tools for GStreamer streaming media framework"
	# gst-feedback needs this
	depends="pkgconfig"

	amove usr/bin
}

sha512sums="
81b50013adbaa30964fc909b53b72304aba43dfeefba40aaa1f75a7163da783bcf53622da8adc06990ab78b4705257caec877181283701ba485eee9ea35688b8  gstreamer-1.24.3.tar.xz
"
